package cn.as.youdian.controller;

import cn.as.youdian.entities.CommenResult;
import cn.as.youdian.entities.Word;
import cn.as.youdian.server.WordService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class VocabularyWord {
    @Resource
    private WordService wordService;
    @Resource
    private RestTemplate restTemplate;

    @GetMapping("get/{word}")
    public CommenResult<Word> getWord(@PathVariable("word") String word) {
        Word result = wordService.getWord(word);
        if (word == null) {
            return new CommenResult<>(444, "没有找到单词", null);
        }
        return new CommenResult<>(200, "找到单词", result);


    }
}
